package com.example.javafx.simple;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Accordion;
import javafx.scene.control.Label;
import javafx.scene.control.TitledPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class AccordionExample extends Application {

    @Override
    public void start(Stage primaryStage) {
        // 创建多个 TitledPane
        TitledPane pane1 = new TitledPane("Pane 1", new Label("Content of Pane 1"));
        TitledPane pane2 = new TitledPane("Pane 2", new Label("Content of Pane 2"));
        TitledPane pane3 = new TitledPane("Pane 3", new Label("Content of Pane 3"));

        // 创建 Accordion 容器并添加 TitledPane
        Accordion accordion = new Accordion();
        accordion.getPanes().addAll(pane1, pane2, pane3);

        // 设置默认展开的 TitledPane
        accordion.setExpandedPane(pane1);

        // 将 Accordion 添加到布局
        VBox root = new VBox(accordion);
        Scene scene = new Scene(root, 300, 200);
        
        primaryStage.setTitle("Accordion Example");
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}